package com.shenyun.service.impl;

import com.shenyun.mapper.MemberMapper;
import com.shenyun.mapper.StudentMapper;
import com.shenyun.pojo.Member;
import com.shenyun.pojo.Student;
import com.shenyun.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    StudentMapper mapper;

    @Autowired
    MemberMapper memberMapper;

    @Override
    public List<Student> GetStudentsAll() {
        List<Student> studentList = new ArrayList<Student>();
        studentList = mapper.queryStudents();
        return studentList;
    }

    @Override
    public List<Student> GetStudentById(Integer number) {
        List<Student> studentList = new ArrayList<Student>();
        studentList = mapper.queryStudentById(number);
        return studentList;
    }

    @Override
    public void AddStudent(Student student) {
        mapper.insertStudent(student.getNumber(),student.getName(),student.getGrade(),
                student.getClbum(),student.getGender(),student.getAge());
    }

    @Override
    public void UpdateStudent(Student student) {
        mapper.updateStudentInfo(student.getNumber(),student.getName(),student.getGrade(),
                student.getClbum(),student.getGender(),student.getAge());
    }

    @Override
    public void deleteStudent(Integer number) {
        mapper.deleteStudent(number);
    }

    @Override
    public Member GetStudentNumber(Integer number) {
        Member member = memberMapper.queryMemberStudent(number);
        return member;
    }

    @Override
    public  List<Member> GetMembersStudent(String clbum, String grade) {
        List<Member> members = memberMapper.queryMembersStudent(clbum,grade);
        return members;
    }
}
